//package com.netease.xone.image.cropimage;
//
//import android.app.Activity;
//import android.content.Context;
//import android.content.Intent;
//import android.database.Cursor;
//import android.graphics.Bitmap;
//import android.graphics.Bitmap.CompressFormat;
//import android.net.Uri;
//import android.os.Bundle;
//import android.provider.MediaStore.Images.ImageColumns;
//import android.view.Gravity;
//import android.view.LayoutInflater;
//import android.view.Menu;
//import android.view.MenuItem;
//import android.view.View;
//import android.view.View.OnClickListener;
//import android.widget.ImageView;
//import android.widget.LinearLayout;
//import android.widget.PopupWindow;
//import android.widget.TextView;
//import android.widget.Toast;
//
//import com.netease.blog.db.UserInfo;
//import com.netease.utils.Util;
//import com.netease.wb.R;
//import com.netease.wb.api.BlogApi;
//import com.netease.wb.api.BlogCallBack;
//import com.netease.wb.cropimage.ActivityCropImage;
//import com.netease.wb.image.ImageManager;
//import com.netease.wb.image.ImageManager.IBitmapCb;
//import com.netease.wb.image.ImageUtilities;
//import com.netease.wb.provider.DatabaseHelper.CapturePhoto;
//import com.netease.wb.skinmanager.SkinManager;
//import com.netease.xone.activity.ActivityUtil;
//
//public class EditUserInfoActivity extends ActivityBase implements OnClickListener{
//	private static final String EXTRA_USER_NAME = "user_name";
//	private static final String EXTRA_USER_ID = "user_id";
//	private static final String EXTRA_USER_SCREEN_NAME = "user_screen_name";
//	private static final String IMAGE_URL_EXTRA_VALUE = "image_url";
//	private static final String EXTRA_USER_DESCRIPTION = "user_description";
//
//	private final int PROFILE_SIZE = 256;
//
//
//	private String mImageLocalPath;//����ͼƬ·��
//	private String mImageUrl;//�û���Ϣ��ͼƬurl
//	private String mImagetobeSend;//׼�����͵��ļ�·��
//	private String mName = null;
//    private String mUser_Id = null;
//    private String mScreenName = null;
//    private String mDescription = null;
//
//    private ImageView mProfileimgOld;
//    private TextView mAddImgFromLocal;
//    private TextView mAddImgFromCamera;
//    private TextView mProfileText;
//    private TextView mNickNameText;
//    private TextView mDescriptionText;
//    private TextView mNickNameEdit;
//    private TextView mDescriptionEdit;
//    private TextView mModifyPwd;
//    private LinearLayout m1;
//	private int mTransactionId;
//
//    private final int SELECT_PICTURE = 100;
//	private final int CAPTURE_PHOTO = 101;
//	private final int CROP_IMAGE = 102;
//
//	public static void startUserInfoActivity(Context context,String username,
//			String user_id,String screen_name,String img_url,String description){
//
//   	 Intent i = new Intent(context, EditUserInfoActivity.class);
//   	 if (!Util.isStringEmpty(username)) {
//   		 i.putExtra(EXTRA_USER_NAME, username);
//   	 }
//   	 if (!Util.isStringEmpty(user_id)) {
//   		 i.putExtra(EXTRA_USER_ID, user_id);
//   	 }
//   	 if (!Util.isStringEmpty(screen_name)) {
//   		 i.putExtra(EXTRA_USER_SCREEN_NAME, screen_name);
//   	 }
//   	if (!Util.isStringEmpty(img_url)) {
//  		 i.putExtra(IMAGE_URL_EXTRA_VALUE, img_url);
//  	 }
//   	if (!Util.isStringEmpty(description)) {
//  		 i.putExtra(EXTRA_USER_DESCRIPTION, description);
//  	 }
//        context.startActivity(i);
//	}
//	@Override
//	protected void onCreate(Bundle savedInstanceState) {
//		super.onCreate(savedInstanceState);
//		setContentView(R.layout.user_info_edit);
//		this.getContent().setBackgroundColor(SkinManager.getSkinValueColor(this, R.color.bg));
//		Intent  intent = this.getIntent();
//		if (null != intent) {
//        	mName = intent.getStringExtra(EXTRA_USER_NAME);
//        	mUser_Id = intent.getStringExtra(EXTRA_USER_ID);
//        	mScreenName = intent.getStringExtra(EXTRA_USER_SCREEN_NAME);
//        	mImageUrl = intent.getStringExtra(IMAGE_URL_EXTRA_VALUE);
//        	mDescription = intent.getStringExtra(EXTRA_USER_DESCRIPTION);
//        } else {
//        	finish();
//        	return;
//        }
//		mProfileimgOld = (ImageView)findViewById(R.id.old_profileimg);
////		mProfileimgNew = (ProfileImageView)findViewById(R.id.new_profileimg);
//		mAddImgFromLocal = (TextView)findViewById(R.id.old_img);
//		mAddImgFromLocal.setOnClickListener(this);
//		mAddImgFromCamera = (TextView)findViewById(R.id.new_img);
//		mAddImgFromCamera.setOnClickListener(this);
//		mProfileText = (TextView)findViewById(R.id.profile_text);
//		mNickNameText = (TextView)findViewById(R.id.nickname_text);
//		mDescriptionText = (TextView)findViewById(R.id.description_text);
//		mNickNameEdit = (TextView)findViewById(R.id.nickname_edit);
//		mDescriptionEdit = (TextView)findViewById(R.id.description_edit);
//		mNickNameEdit.setOnClickListener(this);
//		mDescriptionEdit.setOnClickListener(this);
//		mModifyPwd = (TextView) findViewById(R.id.modify_password);
//		//skin
//		//mModifyPwd.setBackgroundDrawable(Util.getHdpiDrawable(this, R.drawable.scale_btn_selector));
//		mModifyPwd.setBackgroundDrawable(SkinManager.getSkinDrawable(this, R.drawable.scale_btn_selector));
//		//color
//		mModifyPwd.setTextColor(SkinManager.getSkinColor(this, R.color.button_text));
//		mModifyPwd.setOnClickListener(this);
//
//		m1 = (LinearLayout) findViewById(R.id.m1);
////		m1.setBackgroundDrawable(Util.getHdpiDrawable(this, R.drawable.userinfo_description_bg));
////		mAddImgFromLocal.setBackgroundDrawable(Util.getHdpiDrawable(this, R.drawable.small_btn_selector));
////		mAddImgFromCamera.setBackgroundDrawable(Util.getHdpiDrawable(this, R.drawable.small_btn_selector));
////		mNickNameEdit.setBackgroundDrawable(Util.getHdpiDrawable(this, R.drawable.userinfo_bg_selector));
////		mDescriptionEdit.setBackgroundDrawable(Util.getHdpiDrawable(this, R.drawable.userinfo_bg_selector));
//		//skin
//		m1.setBackgroundDrawable(SkinManager.getSkinDrawable(this, R.drawable.userinfo_description_bg));
//		mAddImgFromLocal.setBackgroundDrawable(SkinManager.getSkinDrawable(this, R.drawable.small_btn_selector));
//		mAddImgFromCamera.setBackgroundDrawable(SkinManager.getSkinDrawable(this, R.drawable.small_btn_selector));
//		mNickNameEdit.setBackgroundDrawable(SkinManager.getSkinDrawable(this, R.drawable.userinfo_bg_selector));
//		mDescriptionEdit.setBackgroundDrawable(SkinManager.getSkinDrawable(this, R.drawable.userinfo_bg_selector));
//
//		//color
//		mAddImgFromLocal.setTextColor(SkinManager.getSkinColor(this, R.color.button_text));
//		mAddImgFromCamera.setTextColor(SkinManager.getSkinColor(this, R.color.button_text));
//		mProfileText.setTextColor(SkinManager.getSkinColor(this, R.color.text_edit_userinfo));
//		mNickNameText.setTextColor(SkinManager.getSkinColor(this, R.color.text_edit_userinfo));
//		mDescriptionText.setTextColor(SkinManager.getSkinColor(this, R.color.text_edit_userinfo));
//		mDescriptionEdit.setTextColor(SkinManager.getSkinColor(this, R.color.edit_edit_userinfo));
//		mNickNameEdit.setTextColor(SkinManager.getSkinColor(this, R.color.edit_edit_userinfo));
//
//
//		setTitle(getString(R.string.edit_myinfo));
//		setTitleRight(0, null, null);
//		fillContent();
//		BlogApi.getInstance().addListener(mCBListener);
//	}
//	@Override
//	protected void onDestroy() {
//		// TODO Auto-generated method stub
//		super.onDestroy();
//		BlogApi.getInstance().removeListener(mCBListener);
//		getContentResolver().delete(CapturePhoto.PHOTO_CAPTURE_URI, null, null);
//	}
//	@Override
//	public void onClick(View view) {
//		 //String screen_name = muserinfo_screen_name.getText().toString();
//		 switch (view.getId()) {
//		 case R.id.old_img:
//			 ActivityUtil.selectPictureForResult(this, SELECT_PICTURE);
//			 break;
//		 case R.id.new_img:
////			 ActivityUtil.captureSmallPhotoForResult(this, CAPTURE_PHOTO);//���ֵ�������޷��������
//			 if(!ActivityUtil.haveCamera()){
//				Toast.makeText(this, R.string.no_camera, Toast.LENGTH_LONG).show();
//				break;
//			 }
//			 ActivityUtil.capturePhotoForResult(this, CAPTURE_PHOTO);
//			 break;
//		 case R.id.nickname_edit:
//			 EditCertainInfoActivity.starEditCertainInfoActivity(this, mName, mDescription, EditCertainInfoActivity.EDIT_INFO_TYPE_NICKNAME);
//			 break;
//		 case R.id.description_edit:
//			 EditCertainInfoActivity.starEditCertainInfoActivity(this, mName, mDescription, EditCertainInfoActivity.EDIT_INFO_TYPE_DESCRIPTION);
//			 break;
//		 case R.id.modify_password:
//			 ModifyPassWord.StartModifyPwd(this);
//			 break;
//		 default:
//			break;
//		 }
//	}
//	private void fillContent() {
//		 if (!Util.isStringEmpty(mName)) {
//			 mNickNameEdit.setText(mName);
//		 }
//		 if (!Util.isStringEmpty(mDescription)) {
//			 mDescriptionEdit.setText(mDescription);
//		 }
//		 if (!Util.isStringEmpty(mImageUrl)) {
//			 ImageManager.getInstance(EditUserInfoActivity.this).getProfile(null, mImageUrl, new IBitmapCb() {
//					@Override
//					public void onGetImage(String missionId, Bitmap bitmap, String localPath) {
//						mProfileimgOld.setImageBitmap(bitmap);
//					}
//					@Override
//					public void onGetImageError(String missionId,
//												int errCode) {
//					}
//					@Override
//					public void onDownloading(int max, int curr) {
//
//					}
//				});
//		 }
//	}
//
//
//	@Override
//	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//		if(resultCode != Activity.RESULT_OK)
//			return;
//
//		if (requestCode == SELECT_PICTURE) {
//			Uri uri = data.getData();
//
////			String file = ActivityUtil.getFilePathFromUrl(this, uri);
////			cropImage(ImageUtilities.getScalBitmap(file, PROFILE_SIZE, PROFILE_SIZE));
//			cropImage(ImageUtilities.getScalBitmap(this, uri, PROFILE_SIZE, PROFILE_SIZE));
//		}
//		else if(requestCode == CAPTURE_PHOTO){
////			Bundle extras = data.getExtras();
////			Bitmap b = (Bitmap) extras.get("data");
////			cropImage(b);
//
//			Cursor c = getContentResolver().query(CapturePhoto.PHOTO_CAPTURE_URI, null, null, null, null);
//			if(c != null && c.moveToFirst()){
//				String file = c.getString(c.getColumnIndex(CapturePhoto.PATH));
//				Bitmap bm = ImageUtilities.getScalBitmap(file, PROFILE_SIZE, PROFILE_SIZE);
//				if(bm != null){
//					cropImage(bm);
//				}
//			}
//
//			if(c != null)
//				c.close();
//		}
//		else if(requestCode == CROP_IMAGE){
//			Bitmap bitmap = data.getExtras().getParcelable(ActivityCropImage.EXTRA_DATA);
//			updateProfileImage(bitmap);
//		}
//		else{
//			super.onActivityResult(requestCode, resultCode, data);
//		}
//	}
//
//	private void cropImage(Bitmap b){
//		ActivityCropImage.actionGetCropImage(this, CROP_IMAGE, b, true);
//	}
//
//	private void updateProfileImage(Bitmap b){
//		if(b == null){
//			return;
//		}
//
//		int w = b.getWidth();
//		int h = b.getHeight();
//		if(w > PROFILE_SIZE || h > PROFILE_SIZE){
//			Bitmap newb = ImageUtilities.getScalBitmap(b, PROFILE_SIZE, PROFILE_SIZE);
//			if(newb != null){
//				b.recycle();
//				b = newb;
//			}
//		}
//		String profile = getCacheDir().getPath()+ "/profile_tobeupdate.png";
//		if(false == ImageUtilities.saveBitMaptoFile(b, profile, CompressFormat.PNG))
//			profile = null;
//		b.recycle();
//
//		waitingSomething(getString(R.string.profile_image_uploading));
//		mTransactionId = BlogApi.getInstance().doUpdateProfileImage(profile);
//	}
//
//	private BlogCallBack mCBListener = new BlogCallBack(){
//		@Override
//		public void onUpdateProfileImage(int transactionId, UserInfo info) {
//			if(mTransactionId != transactionId)
//				return;
//
//			stopWaiting();
//			if(info != null && info.id.equals(mUser_Id)){
//				mImageUrl = info.profile_image_url;
//				fillContent();
//			}
//
//		};
//		@Override
//		public void onUpdateProfileImageError(int transactionId, int errCode, String err) {
//			if(mTransactionId != transactionId)
//				return;
//
//			stopWaiting();
//
//			Toast.makeText(EditUserInfoActivity.this, err, Toast.LENGTH_LONG).show();
//		};
//		@Override
//		public void onUpdateProfile(int transactionId, UserInfo info){
//			if(info != null && info.id.equals(mUser_Id)){
//				mName = info.name;
//				mDescription = info.description;
//				mNickNameEdit.setText(mName);
//				mDescriptionEdit.setText(mDescription);
//			}
//		}
//	};
//
//	@Override
//	public boolean onCreateOptionsMenu(Menu menu) {
//		menu.add(0, MENU_GOHOME, 0, getString(R.string.gohome)).setIcon(R.drawable.menu_gohome);
//
//        return true;
//	}
//
//	@Override
//	public boolean onOptionsItemSelected(MenuItem item) {
//		switch (item.getItemId()) {
//		case MENU_GOHOME:
//			goHome();
//			return true;
//		default:
//			break;
//		}
//
//		return super.onOptionsItemSelected(item);
//	}
//	@Override
//	public void OnChangeSkin(int skinId) {
//		// TODO Auto-generated method stub
//		super.OnChangeSkin(skinId);
//		mModifyPwd.setBackgroundDrawable(SkinManager.getSkinDrawable(this, R.drawable.scale_btn_selector));
//		//skin
//		m1.setBackgroundDrawable(SkinManager.getSkinDrawable(this, R.drawable.userinfo_description_bg));
//		mAddImgFromLocal.setBackgroundDrawable(SkinManager.getSkinDrawable(this, R.drawable.small_btn_selector));
//		mAddImgFromCamera.setBackgroundDrawable(SkinManager.getSkinDrawable(this, R.drawable.small_btn_selector));
//		mNickNameEdit.setBackgroundDrawable(SkinManager.getSkinDrawable(this, R.drawable.userinfo_bg_selector));
//		mDescriptionEdit.setBackgroundDrawable(SkinManager.getSkinDrawable(this, R.drawable.userinfo_bg_selector));
//		//color
//		mAddImgFromLocal.setTextColor(SkinManager.getSkinColor(this, R.color.button_text));
//		mAddImgFromCamera.setTextColor(SkinManager.getSkinColor(this, R.color.button_text));
//		mProfileText.setTextColor(SkinManager.getSkinColor(this, R.color.text_edit_userinfo));
//		mNickNameText.setTextColor(SkinManager.getSkinColor(this, R.color.text_edit_userinfo));
//		mDescriptionText.setTextColor(SkinManager.getSkinColor(this, R.color.text_edit_userinfo));
//		mDescriptionEdit.setTextColor(SkinManager.getSkinColor(this, R.color.edit_edit_userinfo));
//		mNickNameEdit.setTextColor(SkinManager.getSkinColor(this, R.color.edit_edit_userinfo));
//	}
//
//}
